package me.bcloud.web.domain;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class OnlineCounter {

	private static HashMap<String, Long> couterMap = new HashMap<String, Long>();

	public static long getOnline() {
		return couterMap.size();
	}

	public static void resie(String ip) {
		couterMap.put(ip, System.currentTimeMillis());
	}

	public static void reduce() {
		Set<String> ips = couterMap.keySet();

		for (Iterator<String> it = ips.iterator(); it.hasNext();) {
			String ip = it.next();
			Long date = couterMap.get(ip);
			if (System.currentTimeMillis() - date > 100000) {

				it.remove();
			}
		}

	}
}
